Title Banner

Running CFM-68K Code at Interrupt Time: Is Your Code at Risk?

By Karen Wenzel
Apple CFM Team
wenzel@apple.com

CONTENTS

Defining the Problem

Examples of Risky Code

Summary
Running CFM-68K code at interrupt time is a risky business for Apple developers. If Code Fragment Manager-68K code does run at interrupt time, it can cause an invalid A5 register value for some classic 68K code that executes after the interrupt. Though documented in the Release notes on E.T.O #21, some developers may not be aware of the limitation, i.e., running CFM-68K code at interrupt time. This limitation exists in all versions of CFM-68K and therefore only applies to code running on 68K machines. Developers may assume that all code that runs on the PowerPC when ported to CFM-68K should run equally well on 68K machines. In the case of code that runs in interrupt time, however, this is not true.

If you are developing or using CFM-68K code, you should read this Technote to determine if your code is at risk.

Defining the Problem

The problem occurs when CFM-68K code is running and an interrupt causes CFM-68K code to be invoked. As a consequence, the value of the classic A5 register may be destroyed. The problem involves the 68K version of Mixed Mode and its interaction with the interrupt system. During execution of CFM-68K code, Mixed Mode maintains an A5 value for classic 68K code. If an interrupt occurs in which CFM-68K code executes, Mixed Mode's A5 value that is held for classic code will get destroyed. When the classic code resumes execution, its A5 register value is invalid and all subsequent A5-relative references also become invalid (e.g., global data references). As result, the classic 68K code will most likely crash your system.


Note:
This problem does not exist on the PowerPC due to the integration of interrupts and Mixed Mode by a nanokernel.

Examples of Risky Code

The following are examples of interrupt (exception)-time execution during which CFM-68K code must not be executed:

  • Deferred tasks
  • VBL tasks
  • I/O completion routines
  • Pre-emptive threads
  • Processor exceptions
This includes cases where:
  • CFM-68K code is wrapped in a routine descriptor and passed to the system as one of the above interrupt time routines (e.g., as an I/O completion routine);
  • CFM-68K code is called from within an interrupt handler;
  • Classic 68K code that wraps a CFM-68K implementation and is called from an interrupt handler/routine;
  • Interrupt-safe traps that are patched with a CFM-68K routine descriptor (or with classic code which invokes CFM-68K code).

If you are a provider of a classic 68K service -- e.g., a static library -- whose implementation uses CFM-68K code, you should document this fact for your clients. Your clients need to be aware that your services cannot be invoked at interrupt time.


Summary

Apple currently does not support the use of CFM-68K code at interrupt time. For those developers who want to use CFM-68K code at interrupt time, Apple is working on a solution. Future versions of CFM-68K may support some use of CFM-68K code at interrupt time. If you are currently using CFM-68K code at interrupt time, you need to take the necessary steps to only use classic 68K code at interrupt time.


Further References


Downloadables

Acrobat version of this Note (132K)


ClarisWorks 4 version of this Note (14K)

Acknowledgments

Thanks to Erik Eidt, Jeff Cobb, Alan Lillich, Allan Foster, David Gaxiola, Pete Gontier, Peri Frantz, and Tim Swihart.


Send feedback to wenzel@apple.com
Updated: 7-Nov-96

Tech Support
Technotes
Previous Technote | Contents

Navigation graphic, see text links

Main| Top of Section | What's New | Apple Computer, Inc. | Find It | Feedback | Help